/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HMFS_UTILS_H
#define HMFS_UTILS_H

// #include "hilog/log.h"

#ifdef __cplusplus
extern "C" {
#endif  // __cplusplus

#ifndef HMFS_FILE_NAME
#define HMFS_FILE_NAME   (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__))
#endif

#define HMFS_DOMAIN (0xD002C00 + 0x12)
#ifndef HMFS_LABEL
#define HMFS_LABEL "HMFS_TOOLS"
#endif

#undef LOG_TAG
#define LOG_TAG HMFS_LABEL
#undef LOG_DOMAIN
#define LOG_DOMAIN HMFS_DOMAIN

// #define HMFS_LOGI(fmt, ...) \
//     HILOG_INFO(LOG_CORE, "[%{public}s:%{public}d]" fmt, (HMFS_FILE_NAME), (__LINE__), ##__VA_ARGS__)
// #define HMFS_LOGE(fmt, ...) \
//     HILOG_ERROR(LOG_CORE, "[%{public}s:%{public}d]" fmt, (HMFS_FILE_NAME), (__LINE__), ##__VA_ARGS__)
// #define HMFS_LOGD(fmt, ...) \
//     HILOG_DEBUG(LOG_CORE, "[%{public}s:%{public}d]" fmt, (HMFS_FILE_NAME), (__LINE__), ##__VA_ARGS__)
// #define HMFS_LOGW(fmt, ...) \
//     HILOG_WARN(LOG_CORE, "[%{public}s:%{public}d]" fmt, (HMFS_FILE_NAME), (__LINE__), ##__VA_ARGS__)
// #define HMFS_LOGF(fmt, ...) \
//     HILOG_FATAL(LOG_CORE, "[%{public}s:%{public}d]" fmt, (HMFS_FILE_NAME), (__LINE__), ##__VA_ARGS__)

#define HMFS_PRINT(fmt, ...) \
    printf(fmt "\n", ##__VA_ARGS__)

#define HMFS_OUTPUT(level, fmt, ...) \
    printf(fmt, ##__VA_ARGS__)

#define HMFS_INFO(fmt, ...) \
    printf("[%s:%d]Info: " fmt "\n", (__FILE__), (__LINE__), ##__VA_ARGS__)

#define HMFS_ERROR(fmt, ...) \
    printf("[%s:%d]Error: " fmt "\n", (__FILE__), (__LINE__), ##__VA_ARGS__)

#define HMFS_DEBUG(fmt, ...) \
    printf("[%s:%d]Debug: " fmt "\n", (__FILE__), (__LINE__), ##__VA_ARGS__)

#define HMFS_MINOR_DEBUG(fmt, ...) \
    printf("[%s:%d]Debug: " fmt "\n", (__FILE__), (__LINE__), ##__VA_ARGS__)

#define HMFS_TRIVIAL_DEBUG(fmt, ...) \
    printf("[%s:%d]Debug: " fmt "\n", (__FILE__), (__LINE__), ##__VA_ARGS__)

#define HMFS_CHECK(retCode, exper, fmt, ...) \
    if (!(retCode)) {                    \
        HMFS_LOGE(fmt, ##__VA_ARGS__);         \
        exper;                           \
    }

#define HMFS_CHECK_ONLY_EXPER(retCode, exper) \
    if (!(retCode)) {                  \
        exper;                 \
    }                         \

#define HMFS_CHECK_ONLY_LOG(retCode, fmt, ...) \
    if (!(retCode)) {                    \
        HMFS_LOGE(fmt, ##__VA_ARGS__);      \
    }

#ifdef __cplusplus
}
#endif  // __cplusplus


#endif // HMFS_UTILS_H